#include <stdio.h>

//自定义结构体类型
struct Student
{
    int id;
    char *name;
    int age;
    char *gender;
    char *address;
};

//值传递
void showInfo(struct Student stu)
{
    printf("id: %d \n", stu.id);
    printf("name: %s \n", stu.name);
    printf("age: %d \n", stu.age);
    printf("gender: %s \n", stu.gender);
    printf("address: %s \n", stu.address);
}

//指针传递
void showInfo1(struct Student *stu)
{
    printf("id: %d \n", stu->id);
    printf("name: %s \n", stu->name);
    printf("age: %d \n", stu->age);
    printf("gender: %s \n", stu->gender);
    printf("address: %s \n", stu->address);
}

int main(void)
{
    //自定义结构体变量
    struct Student stu1;
    stu1.id=100;
    stu1.name="tom tomas";
    stu1.age=18;
    stu1.gender="男";
    stu1.address="南京市玄武区徐庄软件园";

    struct Student stu2;
    stu2.id=101;
    stu2.name="jerry";
    stu2.age=19;
    stu2.gender="男";
    stu2.address="南京市玄武区徐庄软件园";

    printf("sizeof stu1:%ld\n",sizeof(stu1));
    printf("sizeof stu2:%ld\n",sizeof(stu2));

    //访问结构体变量的属性
    printf("id: %d \n", stu1.id);
    printf("name: %s \n", stu1.name);
    printf("age: %d \n", stu1.age);
    printf("gender: %s \n", stu1.gender);
    printf("address: %s \n", stu1.address);

    //printf("id: %d \n", stu2.id);
    //printf("name: %s \n", stu2.name);
    //printf("age: %d \n", stu2.age);
    //printf("gender: %s \n", stu2.gender);
    //printf("address: %s \n", stu2.address);
    showInfo1(&stu2);
    return 0;
}